<template>
  <div class="page">
    <Navbar title="数据礼包" />
    <div class="search-header">
      <van-search v-model="searchValue" placeholder="请输入您的搜索内容" @keydown.enter="getList">/>
      </van-search></div>
    <div class="content">
      <van-pull-refresh v-model="refreshLoading" @refresh="onRefresh">
        <van-empty v-if="!tableData.length" description="暂无数据" />
        <div class="list">
          <div
            v-for="(item,index) in tableData"
            :key="index"
            class="list-item"
          >
            <div class="header">
              {{ item.projectName }}
            </div>
            <div class="file-list">
              <div
                v-for="(file,index) in (item.files || []).filter(el => el.fileName)"
                :key="index"
                class="file-item"
              >
                {{ file.fileName }}.{{ file.fileUrl.split('.')[file.fileUrl.split('.').length - 1] }}
              </div>
            </div>
            <div class="line" />
            <div class="detail-btn-box f-r j-e">
              <el-button type="primary" size="mini" @click.stop="routerJump(item)">查看全部</el-button>
            </div>
          </div>
        </div>
      </van-pull-refresh>
    </div>
  </div>
</template>

<script>
import refresh from '@/mixins/refresh'
import { http_datapackage, http_problem } from '@/api'
import { problemType, qsStatus, qsType } from '@/eumn'

export default {
  name: 'Project',
  mixins: [refresh],
  data() {
    return {
      filterIcon: require('@/assets/home/filter.png'),
      tableData: [
      ],
      searchValue: ''
    }
  },
  methods: {
    routerJump(item) {
      this.$router.push({
        path: '/data-package-detail',
        query: {
          userId: item.userId,
          projectId: item.projectId,
          id: item.id,
          vconsole: true
        }
      })
    },
    getList() {
      if (this.pageNo > 1) return
      http_datapackage.page({
        ...this.getQueryParams(),
        projectName: this.searchValue
      }).then(res => {
        this.tableData = res.data
        this.refreshLoading = false
      })
    }
  }
}
</script>

<style scoped lang="scss">
.page {
    .search-header {
        background-color: #fff;
        padding: 10px 0;
        padding-right: 0.32rem;
        .filter-box {
            flex-shrink: 0;
            font-size: 12px;
            font-family: PingFang SC;
            font-weight: 500;
            color: #333333;
        }
    }
    .list-item {
        width: 100%;
        background: #FFFFFF;
        border-radius: 10px;
        padding: 17px 26px;
        margin-bottom: 18px;
        .header {
            font-size: 18px;
            font-family: PingFang SC;
            font-weight: 500;
            color: #333333;
            margin-right: 10px;
            margin-bottom: 19px;
        }
        .file-list {
            .file-item {
                font-size: 15px;
                line-height: 16px;
                color: #333333;
                font-weight: 500;
                margin-bottom: 11px;
            }
        }
        .line {
            width: 100%;
            height: 1px;
            background-color:#E2E2E2 ;
            margin: 20px 0 10px 0;
        }
    }
}
</style>
